package com.ruoyi.web.config;

import cn.dev33.satoken.config.SaTokenConfig;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SaTokenConfigure {

    private final SaTokenConfig tokenConfig;

    @Autowired
    private SatokenConfigMapper satokenConfigMapper;

    public SaTokenConfigure(SaTokenConfig tokenConfig) {
        this.tokenConfig = tokenConfig;
    }

    @PostConstruct
    public void setSaTokenConfig() {
        // 设定 StpUtil 使用的 SaTokenConfig 配置参数对象
        // 更多设置 ...
//        SaTokenConfig convert = MapstructUtils.convert(tokenConfig, SaTokenConfig.class);
        SaTokenConfig convert = satokenConfigMapper.toSatokenConfig(tokenConfig);
        convert.setTokenName(convert.getTokenName() + "-user");
//        StpKit.USER.setConfig(convert);
    }

}
